/**
 * Dear programmer:
 * When I wrote this code, only god and I knew how it worked.
 * Now, only god knows it!
 *
 * @author: Pegasus  Date: 2019-02-13 Time: 23:07
 */



import {Action} from "../../../configuration/ActionCreator"
import {FetchStatus, RequestAction, RequestMethod} from "../../../configuration/RequestConfiguration";
import {AppRequestPath} from "../../../configuration/AppConfig";
import {API_PROCEDURE2} from "../../../constant/API";
import global from "../../../configuration/global";

/**
 * 获取数据
 * @str {string}
 * @page {int}页数
 */
export const WHSKAlinusers = 'WHSKAlinusers';
export const retrieveWHSKAlinusers = (str) => {
    let action = Action(WHSKAlinusers);
    return dispatch => dispatch(requestRetrieveWHSKAlinusers(action, str))
};

export const requestRetrieveWHSKAlinusers = (action, str) => {
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            'hotelId': global.hotelId,
            'fu': 'WHSKAlinusersRetrieve',
            'jn': str,
            'jnJson2': {},
        },
        action
    )
};

export const onWHSKAlinusers = (state = {}, action) => {
    switch (action.type) {
        case WHSKAlinusers: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state , fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json , fetchStatus: action.status}
                }
                default: {
                    return {...state , fetchStatus: action.status}
                }
            }
        }
    }
    return state
};


